#!/usr/bin/env python3

import sys
import datetime
import os
import subprocess
import re  # 正则
import os.path

print("run in docker,compile cosine arm")

arch_type="aarch64"
work_space_root="/code"

# os.system('\
#           cd %s/map_engine_src/map_engine_sud_provider_cosine && \
#           ./build.sh make aarch64 release\
#           '%(work_space_root))



map_engine_sdk_source_dir=work_space_root+"/map_engine_src/map_engine_sud_provider_cosine"
map_engine_sdk_source_inc_dir=map_engine_sdk_source_dir+"/include"
map_engine_sdk_source_lib_dir=map_engine_sdk_source_dir+"/lib"

map_engine_sdk_target_dir=work_space_root+"/localization_external/opt/nio/aarch64/cosine"
map_engine_sdk_target_inc_dir=map_engine_sdk_target_dir+"/include/map_module"
map_engine_sdk_target_lib_dir=map_engine_sdk_target_dir+"/lib"

os.system('\
        rm -rf %s/*\
          '%(map_engine_sdk_target_inc_dir))

os.system('\
          cp -rf %s/common %s/map_engine %s\
            '%(\
              map_engine_sdk_source_inc_dir,map_engine_sdk_source_inc_dir,map_engine_sdk_target_inc_dir\
                ))

os.system('\
          rm -rf %s/libmap_module.so %s/libmap_proto.so\
            '%(\
              map_engine_sdk_target_lib_dir,map_engine_sdk_target_lib_dir
              ))

os.system('\
          cp -rf %s/libmap_module.so %s/build_aarch64_Release/map-engine/interface/proto/libmap_proto.so %s\
            '%(\
              map_engine_sdk_source_lib_dir,map_engine_sdk_source_dir,map_engine_sdk_target_lib_dir\
                ))
